package com.pj.wisdomlogistics.ui.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;

import com.pj.wisdomlogistics.R;
import com.pj.wisdomlogistics.entity.CarPoritionInfo;
import com.pj.wisdomlogistics.ui.view.recyclerview.BaseAdapter;
import com.pj.wisdomlogistics.ui.view.recyclerview.BaseViewHolder;
import com.zhy.autolayout.utils.AutoUtils;

/**
 * Created by HelloWorld on 2017/9/8.
 */

public class DriverChooseAdapter extends BaseAdapter<CarPoritionInfo.DriverListBean, BaseViewHolder> {

    public DriverChooseAdapter(Context context) {
        super(context);
    }

    @Override
    public BaseViewHolder createCustomViewHolder(ViewGroup parent, int viewType) {
        return new BaseViewHolder(parent, R.layout.item_rv_driver);
    }

    @Override
    public void bindCustomViewHolder(final BaseViewHolder viewHolder, final int position) {
        AutoUtils.autoSize(viewHolder.itemView);

        final CarPoritionInfo.DriverListBean item = getItem(position);


        viewHolder.getTextView(R.id.tv_name).setText(item.getDriverName());
        viewHolder.getTextView(R.id.tv_phone).setText(item.getDriverTel() + "");

        viewHolder.getView(R.id.ll_layout).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mListener.itemClick(position);
            }
        });
    }

    @Override
    public int getCustomViewType(int position) {
        return 0;
    }


    public listener mListener;

    public interface listener {
        public void itemClick(int position);
    }

    public void setListener(listener mListener) {
        this.mListener = mListener;
    }
}
